package com.agy.filemanager.controller;

import com.agy.filemanager.entity.FileInfo;
import com.agy.filemanager.service.FullSearchService;
import com.agy.filemanager.toolClass.Result;
import com.agy.filemanager.toolClass.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/fullSearch")
public class FullSearchController {

    @Autowired
    private FullSearchService fullSearchService;

    /**
     * 全文检索页面
     * @return  index.ftl 全文检索页面
     */
    @GetMapping("/index")
    public String doView01(){
        return "fullSearch/index";
    }

    /**
     * 全文检索
     * @param keywords  //TODO：jpf-全文检索暂时模糊查询，后期优化
     * @return
     */
    @GetMapping("selectByFullSearch")
    @ResponseBody
    public Map<String,Object> selectByFullSearch(String keywords){
        List<FileInfo> list = this.fullSearchService.selectByFullSearch(keywords);
        Map<String,Object> map = new HashMap<>();
        map.put("total","10");
        map.put("rows",list);
        return map;
    }
}
